package com.hongyun.tms.domain;

import com.google.common.collect.Lists;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 业务附件中间表 Domain
 * </p>
 *
 * @author liPeng
 * @since 2024-06-03
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@Builder(toBuilder = true)
@AllArgsConstructor
@NoArgsConstructor
public class SysFileBusinessDomain {

    @ApiModelProperty(value = "id")
    private Long id;

    @ApiModelProperty(value = "业务id")
    private Long businessId;

    @ApiModelProperty(value = "附件id")
    private Long fileId;


    @ApiModelProperty(value = "创建时间")
    private LocalDateTime createTime;

    @ApiModelProperty(value = "创建人")
    private String creator;

    @ApiModelProperty(value = "更新时间")
    private LocalDateTime updateTime;

    @ApiModelProperty(value = "修改人")
    private String modifier;

    @ApiModelProperty(value = "删除标识")
    private Integer isDeleted;

    /**
     * 封装基础属性
     *
     * @param fileIdList 文件idList
     * @param id         业务id
     * @return packageResult
     */
    public static List<SysFileBusinessDomain> packageBasicInfo(List<String> fileIdList, Long id) {
        List<SysFileBusinessDomain> insertList = Lists.newArrayList();
        for (String fileId : fileIdList) {
            SysFileBusinessDomain fileBusiness = SysFileBusinessDomain.builder()
                    .businessId(id)
                    .fileId(Long.valueOf(fileId))
//                    .creator(AuthUtil.getNickName())
                    .createTime(LocalDateTime.now())
//                    .modifier(AuthUtil.getNickName())
                    .updateTime(LocalDateTime.now())
                    .build();
            insertList.add(fileBusiness);
        }
        return insertList;
    }
}
